package com.demo.exception.service.impl;

import com.demo.exception.exception.ApiException;
import com.demo.exception.exception.Asserts;
import com.demo.exception.pojo.User;
import com.demo.exception.mapper.UserMapper;
import com.demo.exception.service.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 小乌龟
 * @since 2022-11-13
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Override
    public boolean addUser(User user) {
//        throw new ApiException("测试报异常点 controller层返回结果集还是全局异常捕获");
        return save(user);
    }

    @Override
    public boolean updateUser(User user) {
        return updateById(user);
    }

    @Override
    public String test() {
        int goodsNum=0;
        if (goodsNum==0){
//            Asserts.fail("商品已卖完");
            throw new ApiException("UserServiceImpl extends ServiceImpl<UserMapper, User> im");
        }
        return "yes";
    }
}
